package com.example.mybatis.mapper;

import com.example.mybatis.model.UserInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 25228
 * Date: 2025-05-25
 * Time: 17:33
 */
@Mapper
public interface UserinfoMapper {
    @Select("select * from user_info")
    List<UserInfo> selectAll();

    @Select("select * from user_info where id = #{id}")
    UserInfo selectById(Integer id);

    @Select("select * from user_info where age=#{age} and delete_flag=#{deleteFlag}")
    List<UserInfo> selectByAge(Integer age,Integer deleteFlag);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into user_info (username, password, age) values (#{username}, #{password}, #{age})")
    Integer insertUser(UserInfo userInfo);

    @Delete("delete from user_info where id=#{id}")
    Integer deleteById(Integer id);

    @Update("update user_info set password=#{password} where id=#{id}")
    Integer upDateById(UserInfo userInfo);

    @Select("select * from user_info order by id ${order}")
    List<UserInfo> selectByOrder(String order);
}
